package com.qf.utils;

import lombok.Data;

import java.io.Serializable;

/**
 * @author lileijian
 * @create 2021-10-27 16:08
 */
@Data
public class ResUtil implements Serializable {
    private static final long serialVersionUID = 1L;

    private Object data;
    private Integer code;
    private String msg;
    private Long count;

    //成功返回
    public static ResUtil ok() {
        ResUtil resUtil = new ResUtil();
        resUtil.setCode(0);
        resUtil.setMsg("success");
        return resUtil;
    }

    //成功返回 传入data
    public static ResUtil ok(Object data){
        ResUtil resUtil = new ResUtil();
        resUtil.setData(data);
        resUtil.setCode(0);
        resUtil.setMsg("success");

        return resUtil;
    }
    //成功返回 传入data
    public static ResUtil ok(Object data,Long count){
        ResUtil resUtil = new ResUtil();
        resUtil.setData(data);
        resUtil.setCount(count);
        resUtil.setCode(0);
        resUtil.setMsg("success");

        return resUtil;
    }

    //失败返回
    public static ResUtil fail(){

        ResUtil resUtil = new ResUtil();
        resUtil.setCode(-1);
        resUtil.setMsg("fail");

        return resUtil;
    }


}
